<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>嘉童游乐中心-K3对接</title>
<jsp:include page="/common/commonCss.jsp" />
<jsp:include page="/common/commonJs.jsp" />
<script type="text/javascript" src="${basePath}commonJs/tags/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#fkBranId").val('${branId}');
		$("#syncStatus").val('-1');
		initTab("kdeBathcForm");
	});

function initTab(formId) {
		$("#startTimeVal").val($("#startTimeSearch").val())
		$("#endTimeVal").val($("#endTimeSearch").val())
		var form = $("#" + formId);
		var pagenbean = new PageBean(form);
		pagenbean.setTableId("kdeBathcTable");
		pagenbean.setCallback(initTable);
		pagenbean.setFootId("kdeBathcToot");
		setPagebeanObj(pagenbean);
		pagenbean.doPage();
	}
	
	function initTable(data) {
		if (data == null) {
			return;
		}
		trimJsonArray(data); 
		$.each(data, function(ind, obj) {
			var i = ind + 1;
			var time = "";
			if(obj.syncDate != "")
				{
					time = getSmpFormatDate(new Date(obj.syncDate),false);
				}
			var status = obj.syncStatus;
			var syncS =  "";
			if(status == 1)
				{
				syncS = "未确认";
				}
			else if(status == 2)
				{
				syncS = "未启动";
				}
			else if(status == 3)
				{
				syncS = "进行中";
				}
			else if(status == 4)
				{
				syncS = "完成";
				}
			var batchId = obj.pkKdebtId;
			var confiTime = obj.confirmTimeStr;
			
			var htm = "<tr>";
			htm += "<td>" + obj.branName + "</td>";
			htm += "<td class='lv'><a href='#' onclick=\"batche_info('"+batchId+"','"+confiTime+"')\">"+time+"</td>";
			htm += "<td>" + syncS + "</td>";
			htm += "<td>" + getSmpFormatDate(new Date(obj.confirmTime),false) + "</td>";
			htm += "<td>" + getSmpFormatDate(new Date(obj.lastSync),false) + "</td>";
			htm += "<td>" + obj.trialCnt + "</td>";
			htm += "<td>" + obj.undoCnt + "</td>";
			htm += "<td>" + getSmpFormatDate(new Date(obj.compTime),false) + "</td>";
			htm += "<td><input type='button' class='btn_l' value='日志查看'></tr>";
			$("#kdeBathcTable").find("tr:eq(" + ind + ")").after(htm);
		});
	}
	
	//更换门店
	function branSelectFun() 
	{
		$("#fkBranId").val($("#branIdSelect").val());
	}
	
	//对接状态
	function statusSelectFun()
	{
		$("#syncStatus").val($("#statusSelect").val())
	}
	
	//新增
	function addNew()
	{
		javascript:window.location.href='${basePath}k3/findSyncRecord.shtml';
	}
	/*查询明细*/
	function batche_info(batchId,confiTime){
		window.location.href='${basePath}k3/findK3Info.shtml?batchId='+batchId+'&syncDate='+confiTime;
	}
</script>
</head>
<body class="bg">
<c:if test="${!empty info }">
	<script type="text/javascript">
		alertInfo('当前暂无对接数据！');
	</script>
</c:if>
<div class="content m_auto">
	<div class="content_l mt10">
    	<ul>
    		<shiro:hasPermission name="k3/findSyncList.shtml">
        		<li class="content_hover"><a href="${basePath}k3/findSyncList.shtml"><i class="nav_icon_u"></i><br>K3对接</a></li>
       		</shiro:hasPermission>
        </ul>
    </div>
    <div class="content_r mt10">
    	<!---- 内容 --->
		<div class="p20">
        <div class="file_single_dl f14 fixed">
        	<dl>
            	<dd><label>所属门店：</label>
					<!----select--->
					<div class="uboxstyle">
						<select name="language_c" id="branIdSelect" onchange="branSelectFun()">
							<c:choose>
								<c:when test="${branId== '-1' }">
									<option value="-1">全部</option>
									<c:forEach items="${branList }" var="bran">
										<option value="${bran.pkBranId }">${bran.branName }</option>
									</c:forEach>
								</c:when>
								<c:otherwise>
									<c:forEach items="${branList }" var="bran">
										<option value="${bran.pkBranId }">${bran.branName }</option>
									</c:forEach>
								</c:otherwise>
							</c:choose>
						</select>
					</div>
					<!----select--->
				</dd>
				<dd><label>对接状态：</label>
					<!----select--->
					<div class="uboxstyle">
						<select name="language_v" id="statusSelect" onchange="statusSelectFun()">
							<option value="-1">全部</option>
							<option value="1">未确认</option>
							<option value="2">未启动</option>
							<option value="3">进行中</option>
							<option value="4">完成</option>
						</select>
					</div>
					<!----select--->
				</dd>
				<dd><label>对接日期：</label><input type="text" id="startTimeSearch" onclick="WdatePicker({dateFmt:'yyyy/MM/dd',isShowWeek:true,isShowClear:true,readOnly:true,maxDate:'#F{$dp.$D(\'endTimeSearch\')}'})" class="Wdate iput_t w82">
              <span>至</span><input type="text" id="endTimeSearch" onclick="WdatePicker({dateFmt:'yyyy/MM/dd',isShowWeek:true,isShowClear:true,readOnly:true,minDate:'#F{$dp.$D(\'startTimeSearch\')}'})" class="Wdate iput_t w82"></dd>
                <dd class="fr">
                	<input type="button" class="btn fr" value="查询" onclick="initTab('kdeBathcForm');">
                    <input type="button" class="btn fr mr10" value="新增" onClick="addNew();">
                </dd>
            </dl>
        </div>
        <table class="table" id="kdeBathcTable">
        	<tr>
            	<th>所属门店</th>
                <th>对接日期</th>
				<th>对接状态</th>
				<th>确认时间</th>
				<th>最近对接时间</th>
				<th>尝试次数</th>
				<th>未完成记录数</th>
				<th>完成时间</th>
				<th>操作</th>
            </tr>
        </table>
        <!----翻页----->
        
        <div class="page fr m10" id="kdeBathcToot">
        </div>
        <!----翻页----->
		</div>
        <!---- 内容 --->
    </div>
</div>
<form action="${basePath }k3/getKdeBatchList.shtml" id="kdeBathcForm" method="post">
	<input type="hidden" name="fkBranId" id="fkBranId">
	<input type="hidden" name="syncStatus" id="syncStatus">
	<input type="hidden" name="startTimeSearch" id="startTimeVal">
	<input type="hidden" name="endTimeSearch" id="endTimeVal">
</form>

<form action="${basePath }k3/getKdeBatchList.shtml" ></form>
</body>
</html>